package com.huang.foundation.service.impl;

import com.huang.foundation.service.SensitiveWordsService;
import org.springframework.stereotype.Service;
import toolgood.words.StringSearch;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author HuangShen
 * @Date 2022/3/1 13:53
 * @Describe
 */
@Service
public class SensitiveWordsServiceImpl implements SensitiveWordsService {

    @Resource
    private StringSearch stringSearch;



    /**
     * 关键字匹配
     *
     * @param text 原文
     * @return List<String>
     */
    @Override
    public List<String> sensitiveWordsMatch(String text) {
        return stringSearch.FindAll(text);
    }

    /**
     * 敏感字替换
     *
     * @param text 原文
     * @return 替换后的
     */
    @Override
    public String sensitiveWordsReplace(String text) {
        return stringSearch.Replace(text);
    }
}
